package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.player.UserBadge;
import com.yanqu.road.pb.badge.BadgeProto;

import java.util.List;
import java.util.Map;

public class BadgePb {

    public static BadgeProto.BadgeDataMsg.Builder parseBadgeDataMsg(Map<Integer, List<UserBadge>> data) {
        if (null == data) {
            return null;
        }
        BadgeProto.BadgeDataMsg.Builder msg = BadgeProto.BadgeDataMsg.newBuilder();
        for (List<UserBadge> badgeList : data.values()) {
            for (UserBadge userBadge : badgeList) {
                msg.addBadge(parseBadgeTempMsg(userBadge));
            }
        }
        return msg;
    }

    public static BadgeProto.BadgeTempMsg.Builder parseBadgeTempMsg(UserBadge userBadge) {
        BadgeProto.BadgeTempMsg.Builder temp = BadgeProto.BadgeTempMsg.newBuilder();
        temp.setBadgeId(userBadge.getBadgeId());
        temp.setBadgeType(userBadge.getBadgeType());
        temp.setDisperseGoldShow(userBadge.isDisperseGoldShow());
        return temp;
    }

}
